<template>
	<view class="lssued-box">
		<u-navbar back-icon-name="arrow-left" title="发布" v-if="1" title-color="#000000" :title-bold="true" :border-bottom="false">
		</u-navbar>


		<view class="lssued-center" style="color: #000000;">
			<view class="flex justify-between align-center u-border-bottom h100" @click="mapLoca">
				<view class="">
					<i class="cuIcon-locationfill mr20 f32" style="color: #B3B3B3;">
					</i>
					<text class="f28">邀约地点</text>
				</view>
				<view class="">
					<i class="cuIcon-right f36"></i>
				</view>
			</view>


			<view class="flex justify-between align-center h100" @click="showTime = true">
				<view class="">
					<i class="cuIcon-timefill mr20 f32" style="color: #B3B3B3;">
					</i>
					<text class="f28">约会时间</text>
				</view>
				<view class="">
					{{time ? time : ''}}
					<i class="cuIcon-right f36"></i>
				</view>
			</view>

			<view class="mt22 h502 r10 pt30 pr30 pl30 pd30" style="background-color: #F7F5F7;">
				<u-input v-model="value" maxlength="500" :clearable="false" placeholder="简单描述具体活动时间、转账方式等"
					type="textarea" />
			</view>
			<view class="flex justify-between align-center mt26 f24" style="color:#666666 ;">
				<text></text>
				<text>{{init}}/500</text>
			</view>

			<view class="flex justify-center " style="margin-top: 301rpx; padding-bottom: 100rpx;">
				<button type="default" class=" cu-btn w500 h80 r40"
					style="color: #FFFFFF; background-color: #000000;" @click="paly">支付并发起邀约
				</button>
			</view>
			
			
			<!-- <view class="mt300">
				<button type="default">支付并发起邀约</button>
			</view> -->

		</view>


		<u-popup border-radius="20" width="520" v-model="showMember" mode="center">
			<view class="text-center pt53 mb45">
				<view class="f28">
					<text>成为会员才能发布急约哦~</text>
				</view>

				<button type="default" class="cu-btn mt45 f30"
					style="color: #FFFFFF; background-color: #000000;">成为会员</button>
			</view>
		</u-popup>


		<u-picker v-model="showTime" mode="time" @confirm="addTime" :params="params"></u-picker>
		<view class="foot_box"></view>
		<!-- 加载提示 -->
		<yy-loading text="加载中.." mask="true" click="true" ref="loading"></yy-loading>
		<!-- 信息提示-->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import amap from '@/commonsdk/SDK/amap-wx.js';
	export default {
		data() {
			return {
				classList: [{
					name: '普通'
				}, {
					name: '急约'
				}],
				list: [{
					text: '约饭'
				}, {
					text: '演出展览'
				}, {
					text: '喝酒蹦迪'
				}, {
					text: '看电影'
				}, {
					text: '密室桌游'
				}],
				value: '',
				init: 0,
				showMember: false,
				showTime: false,
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: false,
					timestamp: true,
				},
				time:'',
				timestamp: '',
				address: '',
				inviteContext: '',
			};
		},
		onShow() {},
		onLoad(e) {},
		watch: {
			value(newValue, oldValue) {
				this.init = newValue.length
				this.inviteContext = newValue
				console.log('newValue, oldValue==>', newValue, oldValue);
			},
		},
		methods: {
			mapLoca() {
				var that = this
				uni.chooseLocation({
					success: function(res) {
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
						that.address =  res.name + res.address 
					}
				});
			},

			addTime(e) {
				this.time = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute
				this.timestamp = e.timestamp
			},
			
			async paly() {
				var obj = uni.getStorageSync('objInit')
				const res = await this.$u.post('api/user/square/invite/add',{
					inviteAddr: this.address ? this.address : '成都犀浦地铁站',
					inviteContext: this.inviteContext,
					inviteDate: this.timestamp + '',
					inviteImg: obj.imgUrl,
					isShowInviteMembers: obj.uni,
					kind:obj.yueding,
					themeId: obj.themeId,
				})
				this.l.msgg(res.msg)
				if (res.code == 200) {
					uni.removeStorageSync('objInit');
					this.l.to('/pages/tab/index')
					// uni.switchTab({
					// 	url:'/pages/tab/index'
					// })
				}
			}
		}
	};
</script>

<style lang="scss" scoped>
	.lssued-box {

		.lssued-center {
			padding: 30rpx;
			height: 100%;

		}
	}
</style>
